package com.fulei.logic;

import android.annotation.SuppressLint;

import com.bjfl.saleManager.util.LogUtil;
import com.dwin.navy.serialportapi.SerailPortOpt;

@SuppressLint({"SdCardPath"})
public class MeiBillOrCoin
{
  private static SerailPortOpt serialPort = null;
  public static String comNo = "";
  public static String baudRate = "";
  public static int[] BillMount = { 5, 10 };
  public static double CardinalNumber = 1.0D;
  public static int PollFailTimes = 0;
  
  public static boolean OpenPort()
  {
    serialPort = new SerailPortOpt();
    
    serialPort.mDevNum = Integer.parseInt(comNo);
    
    serialPort.mSpeed = Integer.parseInt(baudRate);
    serialPort.mDataBits = 8;
    serialPort.mStopBits = 1;
    if (serialPort.mFd == null)
    {
      serialPort.openDev(serialPort.mDevNum);
      serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
    }
    return true;
  }
  
  public static void closeSerialPort()
  {
    if (serialPort.mFd != null) {
      serialPort.closeDev(serialPort.mFd);
    }
    serialPort.mFd = null;
    serialPort = null;
  }
  
  public static int Reset()
  {
    int return_data = 0;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 48 };
      
      LogUtil.writeAcceptCashLog("ResetSend:" +
        LogUtil.bytesToHexString(SendData, SendData.length));
      
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.readBytes(ConfirmData, 1, 1);
      
      LogUtil.writeAcceptCashLog("ResetRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        
        LogUtil.writeAcceptCashLog("ResetWrite:" +
          LogUtil.bytesToHexString(ReConfirmData, ReConfirmData.length));
        
        serialPort.writeBytes(ReConfirmData);
        
        return_data = 1;
      }
      else
      {
        return_data = -1;
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("Reset:" + ex.getMessage());
      return_data = -1;
    }
    return return_data;
  }
  
  public static byte[] GetSetup()
  {
    byte[] Result = null;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 49 };
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.readBytes(ConfirmData, 200, 10);
      if (ConfirmDataLength > 10)
      {
        byte[] ReConfirmData = { 0 };
        serialPort.writeBytes(ReConfirmData);
        Result = new byte[ConfirmDataLength];
        System.arraycopy(ConfirmData, 0, Result, 0, ConfirmDataLength);
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("GetSetup:" + ex.getMessage());
    }
    return Result;
  }
  
  public static byte[] GetBillCount()
  {
    byte[] Result = null;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 54 };
      
      serialPort.mParity = 109;
      
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.readBytes(ConfirmData, 20, 1);
      if (ConfirmDataLength > 10)
      {
        byte[] ReConfirmData = { 0 };
        serialPort.writeBytes(ReConfirmData);
        Result = new byte[ConfirmDataLength];
        System.arraycopy(ConfirmData, 0, Result, 0, ConfirmDataLength);
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("23" + ex.getMessage());
    }
    return Result;
  }
  
  public static int mPoll()
  {
    int return_data = 0;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 51 };
      
      LogUtil.writeAcceptCashLog("PollSend:" +
        LogUtil.bytesToHexString(SendData, SendData.length));
      
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.MeiReadBytes(ConfirmData, 10, 1);
      
      LogUtil.writeAcceptCashLog("PollRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        LogUtil.writeAcceptCashLog("PollWrite:" +
          LogUtil.bytesToHexString(ReConfirmData, ReConfirmData.length));
        

        serialPort.writeBytes(ReConfirmData);
        for (int p = 0; p < ConfirmData.length - 1; p++) {
          if ((ConfirmData[0] == 0) || 
          





            ((ConfirmData[p] & 0xFF) >= 128))
          {
            byte LocationByte = (byte)(ConfirmData[p] & 0x70);
            if (LocationByte == 0)
            {
              PollFailTimes = 0;
              


              byte BillType = (byte)(0xF & ConfirmData[p]);
              
              int ReceCash = (int)(BillMount[BillType] * CardinalNumber);
              
              LogUtil.writeAcceptCashLog("本次投入的金额:" + ReceCash);
              return ReceCash;
            }
            if (LocationByte == 16)
            {
              PollFailTimes = 0;
              mPutBillToBox();
            }
          }
          else
          {
            if (ConfirmData[p] == 8)
            {
              LogUtil.writeAcceptCashLog("钞箱被取走!!!");
              
              return -3;
            }
            if ((ConfirmData[p] == 9) || (ConfirmData[p] == 6)) {
              PollFailTimes += 1;
            }
          }
        }
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("GetBillCount:" + ex.getMessage());
      return -1;
    }
    return return_data;
  }
  
  public static int mUseBill()
  {
    int return_data = 0;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 52 };
      byte[] Send = { -1, -1, -1, -1, 48 };
      

      LogUtil.writeAcceptCashLog("useBillSend:" +
        LogUtil.bytesToHexString(Send, Send.length));
      
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(Send);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.MeiReadBytes(ConfirmData, 10, 1);
      
      LogUtil.writeAcceptCashLog("useBillRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        serialPort.writeBytes(ReConfirmData);
        LogUtil.writeAcceptCashLog("useBillWrite:" +
          LogUtil.bytesToHexString(ReConfirmData, ReConfirmData.length));
        
        return_data = 1;
      }
      else
      {
        return_data = -1;
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("mUseBill:" + ex.getMessage());
      return_data = -1;
    }
    return return_data;
  }
  
  public static int mRobitBill()
  {
    int return_data = 0;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 52 };
      byte[] Send = { 0, 0, 0, 0, 52 };
      
      LogUtil.writeAcceptCashLog("RobitBillSend:" +
        LogUtil.bytesToHexString(Send, Send.length));
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(Send);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.MeiReadBytes(ConfirmData, 10, 1);
      LogUtil.writeAcceptCashLog("RobitBillRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        serialPort.writeBytes(ReConfirmData);
        LogUtil.writeAcceptCashLog("RobitBillRead:" +
          LogUtil.bytesToHexString(ReConfirmData, ReConfirmData.length));
        
        return_data = 1;
      }
      else
      {
        return_data = -1;
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("mRobitBill:" + ex.getMessage());
      return_data = -1;
    }
    return return_data;
  }
  
  public static void mPutBillToBox()
  {
    try
    {
      byte[] SendData = { 53 };
      byte[] Send = { 1, 54 };
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      

      LogUtil.writeAcceptCashLog("PutBillToBoxSend:" +
        LogUtil.bytesToHexString(Send, Send.length));
      
      serialPort.writeBytes(SendData);
      
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      

      serialPort.writeBytes(Send);
      
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.MeiReadBytes(ConfirmData, 10, 1);
      
      LogUtil.writeAcceptCashLog("PutBillToBoxRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        
        LogUtil.writeAcceptCashLog("PutBillToBoxWrite:" +
          LogUtil.bytesToHexString(ReConfirmData, ReConfirmData.length));
        

        serialPort.writeBytes(ReConfirmData);
      }
      else
      {
        mPutBillToBox();
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("mPutBillToBox:" + ex.getMessage());
    }
  }
  
  public static int mTemporary()
  {
    int return_data = 0;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 52 };
      byte[] Send = { -1, -1, -1, -1, 48 };
      

      LogUtil.writeAcceptCashLog("TemporarySend:" +
        LogUtil.bytesToHexString(Send, Send.length));
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(Send);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.MeiReadBytes(ConfirmData, 10, 1);
      
      LogUtil.writeAcceptCashLog("TemporaryRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        serialPort.writeBytes(ReConfirmData);
        return_data = 1;
      }
      else
      {
        return_data = -1;
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("mTemporary:" + ex.getMessage());
      return_data = -1;
    }
    return return_data;
  }
  
  public static void mRobittemporary()
  {
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 52 };
      byte[] Send = { -1, -1, 0, 0, 50 };
      
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(Send);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.MeiReadBytes(ConfirmData, 10, 1);
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        serialPort.writeBytes(ReConfirmData);
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("mRobittemporary:" + ex.getMessage());
    }
  }
  
  public static int coinGetSetupInfo()
  {
    int return_data = 0;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      byte[] SendData = { 9 };
      LogUtil.writeAcceptCashLog("coinGetSetupInfoSend:" +
        LogUtil.bytesToHexString(SendData, SendData.length));
      
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.readBytes(ConfirmData, 1, 1);
      
      LogUtil.writeAcceptCashLog("coinGetSetupInfoRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        
        LogUtil.writeAcceptCashLog("coinGetSetupInfoWrite:" +
          LogUtil.bytesToHexString(ReConfirmData, ReConfirmData.length));
        
        serialPort.writeBytes(ReConfirmData);
        
        return_data = 1;
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("硬币器获取配置信息:" + ex.getMessage());
      return -1;
    }
    return return_data;
  }
  
  public static double coinMoneyPipelineStatus()
  {
    byte[] ReadResult = null;
    
    double result = -1.0D;
    try
    {
      OpenPort();
      
      byte[] SendData = { 10 };
      LogUtil.writeAcceptCashLog("coinGetSetupInfoSend:" +
        LogUtil.bytesToHexString(SendData, SendData.length));
      
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.readBytes(ConfirmData, 1, 1);
      
      LogUtil.writeAcceptCashLog("coinGetSetupInfoRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 3)
      {
        byte[] ReConfirmData = { 0 };
        
        LogUtil.writeAcceptCashLog("coinGetSetupInfoWrite:" +
          LogUtil.bytesToHexString(ReConfirmData, ReConfirmData.length));
        
        serialPort.writeBytes(ReConfirmData);
        

        result = ReadResult[2] + ReadResult[4] + ReadResult[5];
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("硬币器获取钱管状态:" + ex.getMessage());
      return result;
    }
    return result;
  }
  
  public static int coinUsefullAllType()
  {
    int return_data = 0;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 12 };
      byte[] Send = { -1, -1, -1, -1, 8 };
      

      LogUtil.writeAcceptCashLog("coinUsefullAllTypeSend:" +
        LogUtil.bytesToHexString(Send, Send.length));
      
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(Send);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.MeiReadBytes(ConfirmData, 10, 1);
      
      LogUtil.writeAcceptCashLog("coinUsefullAllTypeRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        serialPort.writeBytes(ReConfirmData);
        LogUtil.writeAcceptCashLog("coinUsefullAllTypeWrite:" +
          LogUtil.bytesToHexString(ReConfirmData, ReConfirmData.length));
        
        return_data = 1;
      }
      else
      {
        return_data = -1;
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("coinUsefullAllType:" + ex.getMessage());
      return_data = -1;
    }
    return return_data;
  }
  
  public static int coinForbitAllType()
  {
    int return_data = 0;
    try
    {
      if (serialPort == null) {
        OpenPort();
      }
      if (serialPort.mFd == null)
      {
        serialPort.openDev(serialPort.mDevNum);
        serialPort.setSpeed(serialPort.mFd, serialPort.mSpeed);
        serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      }
      byte[] SendData = { 12 };
      byte[] Send = { -1, -1, -1, -1, 12 };
      

      LogUtil.writeAcceptCashLog("coinForbitAllTypeSend:" +
        LogUtil.bytesToHexString(Send, Send.length));
      
      serialPort.mParity = 109;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(SendData);
      }
      Thread.sleep(1L);
      serialPort.mParity = 115;
      serialPort.setParity(serialPort.mFd, serialPort.mDataBits, serialPort.mStopBits, serialPort.mParity);
      if (null != serialPort.mFd) {
        serialPort.writeBytes(Send);
      }
      byte[] ConfirmData = new byte[512];
      int ConfirmDataLength = serialPort.MeiReadBytes(ConfirmData, 10, 1);
      
      LogUtil.writeAcceptCashLog("coinForbitAllTypeRead:" +
        LogUtil.bytesToHexString(ConfirmData, ConfirmDataLength));
      if (ConfirmDataLength > 0)
      {
        byte[] ReConfirmData = { 0 };
        serialPort.writeBytes(ReConfirmData);
        LogUtil.writeAcceptCashLog("coinForbitAllTypeWrite:" +
          LogUtil.bytesToHexString(ReConfirmData, ReConfirmData.length));
        
        return_data = 1;
      }
      else
      {
        return_data = -1;
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("coinForbitAllType:" + ex.getMessage());
      return_data = -1;
    }
    return return_data;
  }
}
